﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FCMGAAI
{
    public partial class GAForm : Form
    {
        GA1 coba;
        //double[,] mtrix;

        public GAForm(ref GA1 _GA)
        {

            coba = _GA;

            InitializeComponent();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            PopulasitextBox.Text = "100";
            GenerasitextBox.Text = "200";
            CrossovertextBox3.Text = "0.9";
            MutasitextBox.Text = "0.2";

            int populasi = Convert.ToInt32(PopulasitextBox.Text);
            int generasi = Convert.ToInt32(GenerasitextBox.Text);
            double pc = Convert.ToDouble(CrossovertextBox3.Text);
            double pm = Convert.ToDouble(MutasitextBox.Text);



            coba.ConstructAlgen(populasi, generasi, pc, pm);
            coba.regenerasi();


            //String output = "";

            //for (int i = 0; i < coba.anggotaa.Length; i++)
            //{
            //    output = output + "Letak : " + coba.letakk[i] + "\r\n";// +" , Letak : " + coba.letakk[i] + "\r\n";
            //}

            fillGridDataHasil();

            // MessageBox.Show(output);




        }


        public void fillGridDataHasil()
        {

            string[] Label = { "NamaEcoli", "Clustering FCM", "Clustering GA"};
            string[,] Data = new string[coba.letakk.Length, 3];



            for (int i = 0; i < Data.GetLength(0); i++)
            {
                Data[i, 0] = coba.anggotaa[i].ToString();
                Data[i, 1] = coba.coba.Ecoli[i].HasilClustering.ToString();
                Data[i, 2] = coba.letakk[i].ToString();

            }

            UIHelper.FillGrid(ref dataGridViewGA, Label, Data);

        }


    }
}
